package HomeWork.Chapter03;

/**
 * Enjoy programming!!!
 * Time: 2021/11/4 -  19:43
 */
public class SummationFor04 {
    public static void main(String[] args){
        double sum = 0;
        int factorial;//表示分母

        for (int i = 1; i <= 20; i++ ){//用i表示分母最后一项和合的第几项
            factorial = 1;
            for (int j = 1; j <= i; j++){
                factorial *= j;
            }
            sum += 1.0 / factorial;
        }
        System.out.println(sum);
    }
}
